package com.stepshop.wechat.utils;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * 签名类
 * @author sung
 *
 */
public class Signature {
	/**
	 *根据Map获得 sign 
	 *@param map 发送参数map
	 *@return sign(签名)
	 */
	public static String getSign(Map<String,String> map){
		StringBuffer signBuffer=new StringBuffer();
		Set<String> keySet = map.keySet();
		Iterator<String> iterator = keySet.iterator();
		while (iterator.hasNext()) {
			String key =  iterator.next();
			if(key!=null&&(!"".equals(key))){
				String value = map.get(key);
				signBuffer.append(key+"="+value+"&");
			}
		}
		String buCode="sg007testANDSUPERwEr3opJvs4dfwog";
		signBuffer.append("key="+buCode);
		return MD5Util.MD5Encode(signBuffer.toString(), "UTF-8").toUpperCase();
	}
}
